package Thread_;

public class ThreadTest {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(new T1());
        for (int i = 1; i <= 10; i++){
            System.out.println("hi" + i);
            Thread.sleep(1000);
            if(i == 5){
                t.start();
                t.join();
            }
        }
        System.out.println("主线程结束...");
    }
}


class T1 implements Runnable{
    int count = 0;
    @Override
    public void run() {
        while(true){
            System.out.println("hello" + (++count));
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            if(count == 10){
                System.out.println("子线程退出...");
                break;
            }
        }
    }
}